﻿<?php
session_start();
$_SESSION['_code']=rand(1,9999);
require('conn.php');
//require('session.php');
require('functions.php');
//print_r($userdata);
// var_dump($_COOKIE['login']);
//全站访问
if($config['fangwen']==4){
	exit('网站正在更新');
}	
//有效访问时间
if(is_numeric($config['ReadTime'])){
	$readtime=$config['ReadTime']*1000;
}else{
	$readtime=0;
}
$aid=guolv($_GET['aid']);//文章id
$uid=guolv($_GET['uid']);//用户id
$is_logined=$_COOKIE['login'];
$ip=GetIP();

//获取文章信息
if(is_numeric($aid)){
	$row=$mysql->query("select * from `article` where `id` in({$aid}) limit 1");
	if($row){
		$data=$row[0];
		$_pic=str_replace('[weixin]','',$data['pic']);
		if($data['pv_max']!==0 && $data['pv_max']!=='-1'){
			if($data['pv']>=$data['pv_max']){
				exit('文章已过期');	
			}
		}


		$顶部广告=$mysql->query("select * from `addata` where `ad_type`='顶部广告'");//广告
		$底部广告=$mysql->query("select * from `addata` where `ad_type`='底部广告'");//广告
	}else{
		exit('文章已过期');	
	}
}else{
	_location($site,301);
	exit;
}

//访问限制
if($config['fangwen']=='2,5'){
		if(is_weixin()==false || is_QQ()==false){
			$long="{$site}/detail.php?uid={$uid}&aid={$aid}"; 
			echo "<title>{$data['title']}</title>";
			echo "<div style=\"height:0;overflow:hidden;\"><img src=\"http://img01.store.sogou.com/net/a/04/link?appid=100520031&w=710&url={$_pic}\"></div>";
			echo "<center><img src='http://qr.liantu.com/api.php?&bg=ffffff&fg=cc0000&text=".urlencode($long)."'><br />";	
			exit;//仅限微信、QQ访问
		}
}

if($config['fangwen']==1){
	if(is_mobile()==false){
		$long="{$site}/detail.php?uid={$uid}&aid={$aid}"; 
		echo "<title>{$data['title']}</title>";
		echo "<div style=\"height:0;overflow:hidden;\"><img src=\"http://img01.store.sogou.com/net/a/04/link?appid=100520031&w=710&url={$_pic}\"></div>";
		echo "<center><img src='http://qr.liantu.com/api.php?&bg=ffffff&fg=cc0000&text=".urlencode($long)."'><br />";
		exit;//仅限手机访问
	}
}

if($config['fangwen']==2){
		if(is_weixin()==false){
			$long="{$site}/detail.php?uid={$uid}&aid={$aid}"; 
			echo "<title>{$data['title']}</title>";
			echo "<div style=\"height:0;overflow:hidden;\"><img src=\"http://img01.store.sogou.com/net/a/04/link?appid=100520031&w=710&url={$_pic}\"></div>";
			echo "<center><img src='http://qr.liantu.com/api.php?&bg=ffffff&fg=cc0000&text=".urlencode($long)."'><br />";
			exit;//仅限微信访问		
		}
}

// setcookie("sdone");
// print_r($_COOKIE);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
<title><?php echo $data['title']?></title>
<meta name="keywords" content="<?php echo $data['title']?>"/>
<meta name="description" content="<?php echo $data['title']?>"/>
<link rel="stylesheet" type="text/css" href="static/hz.css" media="all">
<div style="height:0;overflow:hidden;"><img src="http://img01.store.sogou.com/net/a/04/link?appid=100520031&w=710&url=<?php echo $_pic?>"></div>
<style type="text/css">
#y-iframe{
	position:fixed;
	_position:absolute;
	left:0;
	bottom:0;
	_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));
	z-index:99999;
	padding-top:1px;
	width:100%;
	min-height:81px;
	height:auto;
	_height:81px;
	
}
.iframe-wrap{
	position:relative;
	margin:0 auto;
	width:1003px;
	height:81px;
}
.title{
	margin-top: 1em;
}
.ad_display{
	display: none;
}
.back{
	position: fixed;
	left: 10px;
	bottom: 10px;
	width: 40px;
	height: 40px;
	background:rgba(0,0,0,0.6) ;
	z-index: 999;
	border-radius: 3px;
	background: url('static/images/back.png') no-repeat center center;
    border-radius: 50%;
    border: 1px solid lightgrey;
    box-shadow: 0px 0px 10px grey;
    background-size: contain;
    -webkit-box-shadow: 0px 0px 10px grey;
}
.tjread{
    width: 100%;
    background-color: #f74545;
    text-align: center;
    margin-bottom: 1.5em;
    color: white;
}

.unopen{
	height: 1000px;
	overflow: hidden;
}
</style>

</head>
<body class="mhome" style="font-family:'STXihei';">

<div class="back" id="back"></div>
<div class="article">
  <h1  class="title"><?php echo $data['title']?></h1>
  <div id="tConArt" class="art_co sau">
 				<div class="ad_display">
					<?php 
					foreach ($顶部广告 as $ad_top) {
					if($ad_top['endtime']!==''){
						if(strtotime($ad_top['endtime'])>=time()){
							print <<<table
								<div class="list_d">
						    	<a class="list_dd bor_b" href="{$ad_top['ad_url']}" target="_blank">
								<div class="list_l"><img src="{$ad_top['ad_thumb']}" width="135" height="90"/></div>
								<div class="list_lt">
									<dl class="list_ld">
										<dt>{$ad_top['ad_title']}</dt>
										<dd>阅读量：{$ad_top['pv']} <font color=red>  点击分享赚{$ad_top['ad_profile']}元</font></dd>
									</dl>
								</div>
								</a>
								</div>
table;
						}
					}
					}
					?>
 				 </div>
				<div class="rich_media_content" id="js_content" >
				<!--内容-->
						<div id="neirong" class="unopen">

						<?php echo $data['content']?>
						</div>	
				<div class="ad_display">
					<div class="list">	
					<div class="tjread">推荐阅读</div>
	
<!-- 122221：ad-1 类型：固定广告位 尺寸：336x280-->
<script type="text/javascript">//<![CDATA[
ac_as_id = 122221;
ac_format = 0;
ac_mode = 1;
ac_group_id = 1;
ac_server_base_url = "afp.csbew.com/";
//]]></script>
<script type="text/javascript" src="http://s.csbew.com/k.js"></script>
<!-- 122223：ad-2 类型：固定广告位 尺寸：336x280-->
<script type="text/javascript">//<![CDATA[
ac_as_id = 122223;
ac_format = 0;
ac_mode = 1;
ac_group_id = 1;
ac_server_base_url = "afp.csbew.com/";
//]]></script>
<script type="text/javascript" src="http://s.csbew.com/k.js"></script>
					</div>
				</div>		
		
				</div>


</div>
<!-- more -->
<script type="text/javascript" src="<?php echo $site?>/static/jquery.min.js" ></script>
<script type="text/javascript" src="<?php echo $site?>/static/jquery.touch.js" ></script>
<script type="text/javascript" src="<?php echo $site?>/static/detail.js" ></script>
<script>
	$(document).ready(function(){
		if (window.location.hash) {
			$('.ad_display').removeClass('ad_display');
			$('#back').hide();
		}else{
			$('.ad_display').addClass('ad_display');
			window.location.hash = 'showAD';
		}

		$('#back').on('tap',  function(event) {
			event.preventDefault();
			/* Act on the event */
			window.history.go(-1);
		});
	});
</script>
<script>
var sUserAgent = navigator.userAgent.toLowerCase();
var IsAndroid = sUserAgent.match(/android/i) == "android";
var IsIos = sUserAgent.match(/iphone os/i) == "iphone os";
var _aid = '<?php echo guolv($_GET['aid'])?>';
var _uid = '<?php echo guolv($_GET['uid'])?>';
var _logined = '<?php echo $is_logined?>';
var _ip = '<?php echo getip()?>';
var _host = document.domain;
var _width = window.screen.width;
var _height= window.screen.height;
var _time=parseInt((new Date).getTime()/1000);
var _referer=document.referrer;
var _useragent=navigator.userAgent;
var _url = window.location.href; 
var _cookie = cookieRead("read");
    $(function() {
        var pattern = /^http:\/\/mmbiz/;
        var prefix = 'http://img01.store.sogou.com/net/a/04/link?appid=100520031&w=710&url=';
        $("img").each(function(){
            var src = $(this).attr('src');
            if(pattern.test(src)){
                var newsrc = prefix+src;
                $(this).attr('src',newsrc);
            }
			//$('#js_content').autoIMG();
        });
	})
	
	function checkCookie(){
		if(window.navigator.cookieEnabled){
			return true;
		}else{
			return false;
		}
	}
	
	
	function count(){
			$.post("<?php echo $site?>/count.php?aid="+_aid+"&uid="+_uid+"&ip="+_ip+"&money=<?php echo $data['money']?>"+"&title=<?php echo $data['title']?>"+"&time="+_time+"&width="+_width+"&height="+_height,function(result){
				return false;
			});
	}
	
 	//用户id，广告id不为空，文章已被分享，并且为非注册用户 跳转到计费接口
	if(_uid!=='' && _aid!==''&&window.location.hash&&!_logined){
		setTimeout('count()',<?php echo $readtime?>);
	}		

</script>


<?php 
$mysql->free();
$mysql->close();
?>	<br>
</body>
</html>
